<script src="<?php echo RESOURCE_URL?>/js/jquery.js"></script>
<form id="form_edit">
    <input type="hidden" name="user_id" value="<?php echo $_GET['user_id']?>">
    <table>
        <tr><td>
                <input placeholder="用户名" type="text" name="name" value="<?php echo $user_row['user_name']?>" required>
            </td></tr>
        <tr><td><input type="password" name="pwd" value="<?php echo $user_row['user_password']?>" placeholder="密码" required></td></tr>
        <tr><td>
                <?php if($user_row['user_role']==0){?>
                    <label>学生<input type="radio" name="role" value="0" checked  required></label>
                    <label>老师<input type="radio" name="role" value="1"  required></label>
                <?php }else{?>
                    <label>学生<input type="radio" name="role" value="0"  required></label>
                    <label>老师<input type="radio" name="role" value="1" checked  required></label>
                <?php }?>
                </td></tr>
        <tr><td><input type="button" value="提交"></td></tr>
    </table>
</form>
<script>
    $(function(){
        $('input:button').click(function(){

            //凡是收集表单数据作为传递参数时，用.ajax()方法会更简便
            var data = $('#form_edit').serialize();
            data+= '&edit2=1';
           //alert(data);
            $.ajax({
                type:'post',
                data:data,
                dataType:'json',
                url:'index.php?act=user&op=edit',
                success:function(res){
                    if(res.state){
                        alert(res.msg);
                        window.location.href="index.php?act=user&op=list";
                    }else{
                        alert(res.msg);
                        window.location.reload();
                    }
                }
            });
        });
    })

</script>